home *** CD-ROM | disk | FTP | other *** search
- /* Sprite example
- ** --------------
- ** This example shows you how to set up a 16 colour OCS sprite with a
- ** doubled X axis (32 pixels width). Those with hardware experience will
- ** know that it takes 4 sprite banks to do this successfully in OCS, which
- ** leaves you with another 4 banks to do with what you will. You can do
- ** this same demo in AGA with just 2 banks used.
- **
- ** The sprite is attached to the mouse, so try moving it around a bit.
- */
-
- MODULE 'games','games/games','exec/memory'
-
- PROC main()
- DEF screen:PTR TO gamescreen, palette:PTR TO INT, sparkie:PTR TO sprite,
- zbxy:LONG, timer:LONG
-
- palette := [ $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
- $0000,$0688,$0466,$0344,$0CC0,$0980,$0870,$0650,
- $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF,
- $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
- ]:INT;
-
- screen := [ GSV1,0, -> GameScreen Version
- 0,0,0, -> Screen_Mem1,2,3
- 0, -> ScreenLink
- palette, -> Address of Palette
- 0, -> Address of RasterList
- 32, -> Amount of colours in palette
- 320,256, -> Screen Height, Width, Width/8
- 320,256, -> Pic Height, Width, Width/8
- 1, -> Amt_Planes
- 0,0, -> Top Of Screen, X/Y
- 0,0, -> X/Y pic offsets
- SPRITES OR NOSPRBDR, -> Special attributes
- LORES, -> Screen mode
- INTERLEAVED, -> Screen type
- 0, -> Screen Is Being Displayed?
- 0 -> Reserved
- ]:gamescreen;
-
- sparkie := [ SPV1,0, -> Version number
- 0, -> Bank Number 0
- 0, -> Ptr to graphic
- 100,100, -> Beginning X/Y positions
- 0, -> Current frame
- 16,21, -> Width, Height
- 16, -> Amt of colours
- 16, -> Colour start in palette
- 2, -> Amt of planes
- HIRES OR XLONG, -> Resolution attributes
- 0, -> Position in relation to playfields
- 0,0 -> Private
- ]:sprite;
-
-
- IF gmsbase := OpenLibrary('games.library',0)
- SetUserPri()
- IF (Add_Screen(screen) = ERR_OK)
- sparkie.data := SmartLoad('GAMESLIB:data/sparkie.raw',0,0,MEMF_CHIP)
- Init_Sprite(screen,sparkie)
- Update_Sprite(screen,sparkie)
- Show_Screen(screen)
- zbxy := Read_Mouse(JPORT1)
-
- REPEAT
- IF (timer++ AND $1)
- IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
- ENDIF
- zbxy := Read_Mouse(JPORT1)
- sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
- sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
- Wait_OSVBL()
- Update_Sprite(screen,sparkie)
- UNTIL !(zbxy AND MB_LMB)
-
- FreeMemBlock(sparkie.data);
- Delete_Screen(screen)
- ENDIF
- CloseLibrary(gmsbase)
- ENDIF
- ENDPROC
-
-